<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改医院报模版关系')" />
    <th:block th:include="include :: bootstrap-select-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-report-edit" th:object="${yfDeptReport}">
            <input name="deptId" th:field="*{deptId}" type="hidden">


            <div class="form-group">
                <label class="col-sm-3 control-label is-required">机构：</label>
                <div class="col-sm-8">
                    <select id="deptId" name="deptId" class="form-control noselect2 selectpicker"  data-none-selected-text="请选择报表"
                         disabled required>
                        <option th:each="dept : ${@dep.getDeptAll()}"
                                th:value="${dept.deptId}"
                                th:field="*{deptId}"
                                th:text="${dept.deptName}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">类型：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('yf_report_type')}">
                        <input type="radio" th:id="${'filterType_' + dict.dictCode}" name="filterType"
                               th:value="${dict.dictValue}"
                               th:field="*{filterType}"
                               th:checked="${dict.default}" required>
                        <label th:for="${'filterType_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">报表：</label>
                <div class="col-sm-8">
                    <select id="componentId" name="reportConfig" class="form-control noselect2 selectpicker"  data-none-selected-text="请选择报表"
                            required multiple>
                        <option th:each="report : ${@yf.getReportAll()}"
                                th:value="${report.id}"
                                th:text="${report.rTName}"></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-select-js"/>
    <script type="text/javascript">
        var prefix = ctx + "yf/report";

        var rep  = "[[${yfDeptReport.reportConfig}]]"

        $("#form-report-edit").validate({
            focusCleanup: true
        });

        $("#deptId").selectpicker({
            showTick: true,
            liveSearch: true,
            noneResultsText: "没找到相应记录{0}",
            actionsBox: true,
        });

        $('#componentId').selectpicker('val', rep.split(','));

        $("#componentId").selectpicker({
            showTick: true,
            liveSearch: true,
            noneResultsText: "没找到相应记录{0}",
            actionsBox: true,
            //取消全选按钮标题
            deselectAllText: "取消全选",
            //全选按钮标题
            selectAllText: "全选",
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-report-edit').serialize());
            }
        }
    </script>
</body>
</html>